package com.ruoyi.web.controller.data;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.data.domain.QualityControlVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.data.domain.BusWaterMeteorologicaldata;
import com.ruoyi.data.service.IBusWaterMeteorologicaldataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 气象数据Controller
 * 
 * @author ruoyi
 * @date 2025-08-21
 */
@RestController
@RequestMapping("/data/meteorological")
public class BusWaterMeteorologicaldataController extends BaseController
{
    @Autowired
    private IBusWaterMeteorologicaldataService busWaterMeteorologicaldataService;

    /**
     * 查询气象数据列表
     */
//    @PreAuthorize("@ss.hasPermi('system:METEOROLOGICALDATA:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusWaterMeteorologicaldata busWaterMeteorologicaldata)
    {
        startPage();
        List<BusWaterMeteorologicaldata> list = busWaterMeteorologicaldataService.selectBusWaterMeteorologicaldataList(busWaterMeteorologicaldata);
        return getDataTable(list);
    }

    /**
     * 导出气象数据列表
     */
//    @PreAuthorize("@ss.hasPermi('system:METEOROLOGICALDATA:export')")
//    @Log(title = "气象数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusWaterMeteorologicaldata busWaterMeteorologicaldata)
    {
        List<BusWaterMeteorologicaldata> list = busWaterMeteorologicaldataService.selectBusWaterMeteorologicaldataList(busWaterMeteorologicaldata);
        ExcelUtil<BusWaterMeteorologicaldata> util = new ExcelUtil<BusWaterMeteorologicaldata>(BusWaterMeteorologicaldata.class);
        util.exportExcel(response, list, "气象数据数据");
    }

    /**
     * 获取气象数据详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:METEOROLOGICALDATA:query')")
    @GetMapping(value = "/{locationid}")
    public AjaxResult getInfo(@PathVariable("locationid") String locationid)
    {
        return success(busWaterMeteorologicaldataService.selectBusWaterMeteorologicaldataByLocationid(locationid));
    }

    /**
     * 新增气象数据
     */
//    @PreAuthorize("@ss.hasPermi('system:METEOROLOGICALDATA:add')")
//    @Log(title = "气象数据", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody BusWaterMeteorologicaldata busWaterMeteorologicaldata)
    {
        return toAjax(busWaterMeteorologicaldataService.insertBusWaterMeteorologicaldata(busWaterMeteorologicaldata));
    }

    /**
     * 修改气象数据
     */
//    @PreAuthorize("@ss.hasPermi('system:METEOROLOGICALDATA:edit')")
//    @Log(title = "气象数据", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/edit")
    public AjaxResult edit(@RequestBody BusWaterMeteorologicaldata busWaterMeteorologicaldata)
    {
        return toAjax(busWaterMeteorologicaldataService.updateBusWaterMeteorologicaldata(busWaterMeteorologicaldata));
    }

    /**
     * 删除气象数据
     */
//    @PreAuthorize("@ss.hasPermi('system:METEOROLOGICALDATA:remove')")
//    @Log(title = "气象数据", businessType = BusinessType.DELETE)
	@GetMapping("/remove/{locationids}")
    public AjaxResult remove(@PathVariable String[] locationids)
    {
        return toAjax(busWaterMeteorologicaldataService.deleteBusWaterMeteorologicaldataByLocationids(locationids));
    }

    /**
     * 水质质控数据
     */
    @GetMapping("/getQualityControlData")
    public TableDataInfo getQualityControlData(QualityControlVo vo) {

        startPage();
       List<Map<String,Object>> list =busWaterMeteorologicaldataService.getQualityControlData(vo);

        return getDataTable(list);
    }




}
